# -*-coding:utf-8-*-
'''
File Create by Author:Backpackerxl
Create File Time:2021/10/13/013 21:07
Program IDE:PyCharm
File Name:StartBankSystem.py
  
'''
import sys
import time as t

from control.MangerController import MangerController as manger
from control.UserController import UserController as user_control
from util.WatchInput import WatchInput as u_input
from view.View import View as view


class StartBankSystem:
    def _isOption(self, u_option):
        if u_option == 1:
            user_control.insert_user(self=user_control)
            t.sleep(0.5)
            view.menu(self)
        elif u_option == 2:
            user_control.look_money(self=user_control)
            t.sleep(0.5)
            view.menu(self)
        elif u_option == 3:
            user_control.take_off_money(self=user_control)
            t.sleep(0.5)
            view.menu(self)
        elif u_option == 4:
            user_control.take_in_money(self=user_control)
            t.sleep(0.5)
            view.menu(self)
        elif u_option == 5:
            user_control.move_to_money(self=user_control)
            t.sleep(0.5)
            view.menu(self)
        elif u_option == 6:
            user_control.close_lock_user(self=user_control)
            t.sleep(0.5)
            view.menu(self)
        elif u_option == 7:
            user_control.open_lock_user(self=user_control)
            t.sleep(0.5)
            view.menu(self)
        else:
            print("输入错误")

    def __init__(self):
        view.welcome(self)
        res = manger.login(self, u_input.WatchInput(self, "请输入管理员账号"), u_input.WatchInputPwd(self, "请输入密码"))
        print(res[1])
        view.menu(self) if res[0] else sys.exit()
        while res[0]:
            u_option = u_input.WatchInput(self, '请选择')
            if u_option == 'Q':
                qres = manger.login(self, u_input.WatchInput(self, "请输入管理员账号"), u_input.WatchInputPwd(self, "请输入密码"))
                if qres[0]:
                    user_control.preservation_all_data(self)
                    print("^(*￣(oo)￣)^ Bye ~~")
                    t.sleep(0.5)
                    sys.exit()
                else:
                    print(qres[1], "退出失败,正在为您跳转至菜单页...")
                    t.sleep(0.5)
                    view.menu(self)
            else:
                self._isOption(int(u_option))
